package com.association.controller;

import com.association.logging.aop.log.WebLog;
import com.association.model.ResultResp;
import com.association.model.vo.MenuTitleVo;
import com.association.service.MenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 18244
 */
@RestController
@RequestMapping("/api")
public class MenuController {
    @Resource
    MenuService menuService;

    @Autowired
    private StringRedisTemplate redisTemplate;


    @ApiOperation(value = "查询导航信息")
    @GetMapping("/menus")
    public Map<String, Object> MenuList() {
        Map<String, Object> map = new HashMap<>(3);
        map.put("homeInfo", new MenuTitleVo("首页", "admin/home", ""));
        map.put("logoInfo", new MenuTitleVo("渔柒后台管理", "", "images/logo.png"));
        map.put("menuInfo", menuService.menuList());
        return map;
    }

    @GetMapping("/MenuRouters")
    @WebLog("查询页面路由信息")
    public ResultResp menuRouterList(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        return new ResultResp(menuService.menuRouterList());
    }
}
